//
//  VEShareView.m
//  VEMoneyPorject
//
//  Created by BlueWind on 2018/10/8.
//  Copyright © 2018 陈建. All rights reserved.
//

#import "VEShareView.h"

@interface VEShareView()

@property (nonatomic, strong)UILabel *titleLab;

@property (nonatomic, strong)UILabel *contentLab;

@end


@implementation VEShareView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.alertViewHeight = 200.5;
        [self loadDefaultSetting];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)decoder {
    if (self = [super initWithCoder:decoder]) {
        [self loadDefaultSetting];
    }
    return self;
}

- (void)loadDefaultSetting {
    
    UIImageView *VEImageView = [UIImageView new];
    [self addSubview:VEImageView];
    [VEImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(GAP15);
        make.top.equalTo(self).offset(GAP15);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    VEImageView.image = IMG(@"图形3");
    UILabel *VELab = [UILabel new];
    [self addSubview:VELab];
    [VELab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(VEImageView);
        make.left.equalTo(VEImageView.mas_right).offset(GAP8);
    }];
    VELab.text = @"VE 财经";
    VELab.font = kFont(14);
    
    UIImageView *shareImage = [UIImageView new];
    [self addSubview:shareImage];
    [shareImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(VEImageView.mas_bottom).offset(GAP8);
        make.height.mas_equalTo(50);
    }];
    shareImage.image = IMG(@"标题");
    
    UIView *line = [UIView new];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(shareImage.mas_bottom).offset(GAP8);
        make.left.equalTo(self).offset(GAP15);
        make.right.equalTo(self).offset(-GAP15);
        make.height.mas_equalTo(5);
    }];
    line.backgroundColor = kCommonRedColor;
    
    self.titleLab = [UILabel new];
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(line.mas_bottom).offset(GAP8);
        make.left.equalTo(self).offset(GAP15);
        make.right.equalTo(self).offset(-GAP15);
        make.height.mas_equalTo(30);
    }];
    self.titleLab.font = kBoldFont(16);
    self.titleLab.text = @"这个是快讯的分享这个是快";
    self.titleLab.adjustsFontSizeToFitWidth = YES;
    
    UIView *messageView = [UIView new];
    [self addSubview:messageView];
    [messageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-GAP8);
        make.left.equalTo(self).offset(GAP15);
        make.right.equalTo(self).offset(-GAP15);
        make.height.mas_equalTo(100);
    }];
    messageView.backgroundColor = [UIColor whiteColor];
    
    UIView *line1 = [UIView new];
    [self addSubview:line1];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(messageView.mas_top).offset(-GAP8);
        make.left.equalTo(self).offset(GAP15);
        make.right.equalTo(self).offset(-GAP15);
        make.height.mas_equalTo(5);
    }];
    line1.backgroundColor = kCommonRedColor;

    self.contentLab = [UILabel new];
    [self addSubview:self.contentLab];
    [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom).offset(GAP8);
        make.bottom.equalTo(line1.mas_top).offset(-GAP8);
        make.left.equalTo(self).offset(GAP15);
        make.right.equalTo(self).offset(-GAP15);
    }];
    self.contentLab.adjustsFontSizeToFitWidth = YES;
    self.contentLab.textColor = [UIColor blackColor];
    self.contentLab.numberOfLines = 0;
    
    
    UIImageView *QRCODE = [UIImageView new];
    [messageView addSubview:QRCODE];
    [QRCODE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(messageView);
        make.right.equalTo(messageView.mas_right).offset(-GAP15);
        make.size.mas_equalTo(CGSizeMake(90, 90));
    }];
    QRCODE.image = [UIImage imageNamed:@"1513849177"];
    
    UILabel *summary = [UILabel new];
    [messageView addSubview:summary];
    [summary mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(messageView);
        make.right.equalTo(QRCODE.mas_left).offset(-GAP15);
        make.left.equalTo(messageView.mas_left).offset(GAP15);
    }];
    summary.numberOfLines = 0;

    [summary layerBorderWithWidth:0.5 borderColor:[UIColor orangeColor]];
    [summary setLayerCornerRadius:5];
    summary.font = kFont(15);
    summary.textColor = [UIColor colorWithHexString:kDetailTextBlackColor];
    summary.text = @"已有600万人领取，立即扫码注册就送2888 VE财经糖果";
    summary.attributedText = [BHJProjectHelper ls_changeCorlorWithColor:[UIColor redColor] TotalString:summary.text SubStringArray:@[@"2888"]];
    
    
    UILabel *tapLab = [UILabel new];
    [messageView addSubview:tapLab];
    [tapLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(summary.mas_bottom).offset(GAP8);
        make.centerX.equalTo(summary);
    }];
    tapLab.font = kFont(14);
    tapLab.textColor = [UIColor colorWithHexString:kDetailTextBlackColor];
    tapLab.text = @"长按识别二维码，长按可提现";
    tapLab.attributedText = [BHJProjectHelper ls_changeCorlorWithColor:[UIColor redColor] TotalString:tapLab.text SubStringArray:@[@"长按可提现"]];
}

- (void)setTitleStr:(NSString *)titleStr {
    _titleStr = titleStr;
    self.titleLab.text = titleStr;
}

- (void)setContentStr:(NSString *)contentStr {
    _contentStr = contentStr;
    NSMutableAttributedString *attrStr =  [[NSMutableAttributedString alloc] initWithData:[contentStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    [attrStr setAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:15.0],NSForegroundColorAttributeName:[UIColor colorWithHexString:kDetailTextBlackColor]} range:NSMakeRange(0, attrStr.length)];

    self.contentLab.attributedText = attrStr;

    
}




@end
